package com.xy.shop.common.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author jxp
 **/
@Component
public class SchedulerTask {


    @Value("${juhe.phones}")
    private String phones;

    @Value("${juhe.sendFlag}")
    private Boolean sendFlag;

    @Value("${juhe.smsUrl}")
    private String smsUrl;

    @Value("${juhe.smsTplid}")
    private String smsTplid;

    @Value("${juhe.smsKey}")
    private String smsKey;


    /**
     * @Description 存储过程异常短信报警
     * @Author jxp
     **/
    @Scheduled(cron="0 */10 * * * ?")
    private void proLog(){
        //查看最近十分钟存储过程执行异常数
       /* int errorNum = procExecLogService.selectErrorNumByTime();
        if(errorNum > 0 && sendFlag){
            JuheUtil.sendSms(smsUrl,smsKey,smsTplid,phones);
        }*/
    }

    /**
     * @Description 数据同步异常短信报警
     * @Author jxp
     **/
    @Scheduled(cron="0 */30 * * * ?")
    private void baseRecord(){
//        //查看最近半小时base_play_record中是否有新数据
//        List<DimApp> dimApps = dimAppService.selectAll();
//        for(DimApp dimApp: dimApps){
//            int num = basePlayRecordService.selectNumByTime(dimApp.getAppId());
//            if(num == 0 && sendFlag){
//                JuheUtil.sendSms(smsUrl,smsKey,smsTplid,phones);
//                break;
//            }
//        }
    }
}
